package cn.edu.sdjzu.knoverse.service.impl;

import cn.edu.sdjzu.knoverse.mapper.PowerMapper;
import cn.edu.sdjzu.knoverse.model.entity.system.Power;
import cn.edu.sdjzu.knoverse.model.vo.system.rolePower.PowerVo;
import cn.edu.sdjzu.knoverse.service.PowerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 权限 服务实现类
 */
@Service
@Transactional
public class PowerServiceImpl extends ServiceImpl<PowerMapper, Power> implements PowerService {

    /**
     * * 获取所有权限
     *
     * @return 所有权限列表
     */
    @Override
    public List<PowerVo> getAllPowers() {
        List<Power> powerList = this.list();
        return powerList.stream().map(power -> {
            PowerVo powerVo = new PowerVo();
            BeanUtils.copyProperties(power, powerVo);
            return powerVo;
        }).toList();
    }
}
